package com.lb.activity.config.shiro;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * Created with IntelliJ IDEA.
 * Description: 验证密码
 * User: liubin
 * Date: 2017-11-02
 * Time: 上午 10:03
 * @author 001030
 */
public class CredentialsMatcher extends SimpleCredentialsMatcher{


    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        UsernamePasswordToken utoken = (UsernamePasswordToken) token;
        //获取用户输入的密码（可以采用加盐的方式）
        String inPassWord = new String(utoken.getPassword());
        //获取数据库的密码
        String dbPassWord = (String) info.getCredentials();
        //进行比对  注意toString
        return this.equals(inPassWord,dbPassWord);
    }



}
